//
//  ViewController.h
//  babykicks
//
//  Created by 彤辉 沈 on 12-2-13.
//  Copyright (c) 2012年 __MyCompanyName__. All rights reserved.
//

#import <UIKit/UIKit.h>
#import <sqlite3.h>
#import <AVFoundation/AVFoundation.h>

@interface ViewController : UIViewController<UITableViewDelegate,UITableViewDataSource>{
    UITableView* result;//每点击一次，就刷新一次
    UILabel* countdown;//倒计时
    UIButton* startButton;//开始按钮
    UIButton* recordButton;//记录按钮
    //UIButton* cancelButton;//取消按钮
    NSInteger number;//记录胎动次数
    NSMutableArray* date;//记录胎动的时间
    NSDate* currentDate;//用当前时间减去倒计时开始时的时间，计算已经用过的时间
    NSDate* recordDate;//刚开始记录时的时间
    sqlite3* database;//数据库
    NSTimer* timer;//用于进行计时
    BOOL started;//确定此时状态是否正在记录
    //AVAudioPlayer* player;
}

@property(nonatomic,retain)IBOutlet UITableView* result;
@property(nonatomic,retain)IBOutlet UILabel* countdown;
@property(nonatomic,retain)IBOutlet UIButton* startButton;
@property(nonatomic,retain)IBOutlet UIButton* recordButton;
//@property(nonatomic,retain)IBOutlet UIButton* cancelButton;
@property(nonatomic,retain)NSMutableArray* date;
@property(nonatomic,retain)NSDate* currentDate;
@property(nonatomic,retain)NSDate* recordDate;
@property(nonatomic,retain)NSTimer* timer;
//@property(nonatomic,retain)AVAudioPlayer* player;

-(IBAction)start:(id)sender;//开始记录
-(IBAction)record:(id)sender;//“记录”按钮的动作
-(IBAction)viewPast:(id)sender;//查看过往记录

-(void)startRecord;
-(void)cancel;
-(void)timeFire;
-(BOOL)openDB;//打开数据库
-(BOOL)createTable:(sqlite3*)db;//第一次打开时创建数据库
-(BOOL)insertToStarttime:(NSDate*)date;//将数据插入starttime表
-(BOOL)insertToRecordtime:(NSDate*)date;//将数据插入recordtime表
-(NSArray*)selectStarttime;//从starttime表中读取数据，将数据打包成array返回
-(NSArray*)selectRecordtime;//从recordtime表中读取数据，将数据打包成array返回
-(void)done;//当记录达到一个小时要做的事

@end